<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">

<head>
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet" th:href="@{/res/css/amazeui.min.css}" />
    <link rel="stylesheet" th:href="@{/res/css/admin.css}" />
    <script type="text/javascript" th:src="@{/js/jquery-1.11.3.min.js}"></script>
    <script th:src="@{/myplugs/js/plugs.js}"></script>
</head>

<style>
    .block{
        width: 400px;
        display: block;
        margin:15px 0;
    }
    .center{
        text-align: center;
    }
    label {
        display: inline-block;
        width: 100px;
        text-align: right;
    }
    input{
        vertical-align: top;
    }
    form{
        position:relative;
        left:35%;
        margin-top: 8%;
    }
    #gotoupdate{
        margin-right: 4%;
    }
</style>

<body>
<div class="admin-content-body">
    <div class="am-cf am-padding am-padding-bottom-0">
        <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">我的信息</strong><small></small></div>
    </div>

    <hr>

    <form class="">
        <fieldset>

            <div class="block">
                <label for="username">用户名:</label>
                <input type="text" class="" id="username" disabled="disabled">
            </div>

            <div class="block">
                <label for="email">邮&nbsp;&nbsp;&nbsp;&nbsp;件:</label>
                <input type="email" class="" id="email" disabled="disabled">
            </div>

            <div class="block">
                <label for="phone">电&nbsp;&nbsp;&nbsp;&nbsp;话:</label>
                <input type="text" class="" id="phone" disabled="disabled">
            </div>

            <div class="block center">
                <a href="" target="right" id="update">
                    <input type="button" id="gotoupdate" class="am-btn am-btn-primary am-round" value="修改信息" />
                </a>
            </div>

        </fieldset>
    </form>
</div>
</body>

<script>
    //id从url得到
    var result=new Object();
    result=getParameter();
    var uid=result["uid"];

    $(function () {
        $.ajax({
            type: 'post',
            url: '/user/selectById',
            data: {uid: uid},
            dataType: 'json',
            success: function (mydata) {
                console.log(mydata);
                document.getElementById("username").value=mydata.name;
                document.getElementById("email").value=mydata.email;
                document.getElementById("phone").value=mydata.phone;
                $("#update").attr("href", "/updateUserMes?uid=" + mydata.id+"&email="+mydata.email+"&phone="+mydata.phone);
            },
            error: function () {
                alert("请求失败！");
            }
        })
    })

    //解析url传值
    function getParameter() {
        var url=location.search;//获取url?后面的内容
        var result=new Object();
        if(url.indexOf("?")!= -1){
            var str=url.substr(1);
            strs=str.split("&");
            for(var i=0;i<strs.length;i++){
                result[strs[i].split("=")[0]]=decodeURIComponent(strs[i].split("=")[1]);
            }
        }
        return result;
    }
</script>
</html>